<?php 
class test extends IController
{
	public function qqlogin()
	{
		$this->redirect('qqlogin');
	}
	public function qq()
	{
		$appid='101353491';			// APPID
		$appkey='df4e46ba7da52f787c6e3336d30526e4';			// APPKEY
		$redirect_uri='http://www.iwebshop.com/index.php';		// 回调地址
		$state = rand(1111,9999);
		$url = "https://graph.qq.com/oauth2.0/authorize?response_type=code&client_id=$appid&redirect_uri=$redirect_uri&state=$state";
		header("location:$url");
	}
	public function regis()
	{
		$this->redirect("regis");
	}
	public function emails()
	{
		$data = $_POST;
		// print_r($data);
		$data['status'] = 0;
		$model = new IModel('acc');
		$model->setData($data);
		$res = $model->add();
		if($res)
		{
			$email = $data['email'];
			$title = "欢迎注册我们的会员";
			$url = "http://www.iwebshop.com/index.php/test/lianjie/id/".base64_encode($res);
			$content = "您好，你的会员已注册成功，请点击此链接激活我们吧	！".$url;
			// echo "<script>alert('注册成功，邮箱已发送，请激活');</script>";
			$mail = new sendmail();
			$mail->send($email,$title,$content);
			echo "注册成功，邮箱已发送，请激活";
		}
	}
	public function lianjie()
	{
		$id = $_GET['id'];
		$id = base64_decode($id);
		// print_r($id);
		$data = array("status"=>1);
		$model = new IModel('acc');
		$model->setData($data);
		$res = $model->update("id = $id");
		if($res)
		{
			// echo "<script>alert('激活成功');</script>";
			echo "激活成功";
			$this->redirect("login");
		}
	}
	public function login_do()
	{
		$names = $_POST['names'];
		$pwd = $_POST['pwd'];
		$model = new IModel('acc');
		$res = $model->query("names='$names' and pwd='$pwd'");
		// print_r($res);
		$status = $res[0]['status'];
		if($status == 1)
		{
			echo "<script>alert('登陆成功');location.href='/site/index'</script>";
			// echo "登陆成功";
		}
		else
		{
			echo "<script>alert('账号未激活，请先激活');location.href='/test/login'</script>";
			// echo "账号未激活，请先激活";
			return false;
		}
	}
}


 ?>